package servlet;

import pagination.PageBean;
import pojo.Brand;
import service.BrandService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "SelectAllServlet", value = "/selectAll")
public class selectAllServlet extends HttpServlet {

     BrandService brandService = new BrandService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        接收分页参数（当前是第？页，每一页为10）
        String currentPage=request.getParameter("currentPage");
        int curPage=1;
        if (currentPage!=null){
            curPage=Integer.valueOf(currentPage);
        }

        int pageSize = 10;
//1. 调用BrandServicePage完成查询
        PageBean<Brand> pageBean = brandService.selectAllPage(curPage,pageSize);
//2. 存入request域中
        request.setAttribute("pageBean",pageBean);
//3. 请求转发到brand.jsp
        request.getRequestDispatcher("/brand.jsp").forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
